# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     main
   Description :
   Author :       Flyoung
   date：          2023/3/15
-------------------------------------------------
   Change Activity:
                   2023/3/15:
-------------------------------------------------
"""
from compiler.state_machine.test import test_case_1 as test_case, test_case_check
from compiler.state_machine.utils import nfa2dfa, simplify_dfa


def main():
    # 定义 NFA
    input_d, start, ends, alphabet = test_case()
    # 获取 DFA
    final_state, dfa_desc, dfa, start_state, end_states = nfa2dfa(
        start,
        alphabet=alphabet,
        start_state=start,
        end_states=ends
    )
    # 简化 DFA
    is_simplified, simplified_dfa, simplified_dfa_desc, simplify_start, simplify_ends = simplify_dfa(
        dfa,
        start_state,
        end_states,
        alphabet
    )
    # 验证
    test_case_check(
        input_d=input_d,
        start=start,
        ends=[ends],
        dfa=dfa,
        dfa_start=start_state,
        dfa_ends=end_states,
        dfa_desc=dfa_desc,
        is_simplified=is_simplified,
        simplified_dfa=simplified_dfa,
        simplify_start=simplify_start,
        simplify_ends=simplify_ends,
        simplified_dfa_desc=simplified_dfa_desc
    )


if __name__ == '__main__':
    main()
